/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jpa.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author carlos
 */
@Entity
@Table(name = "UsuarioCli")
@NamedQueries({
    @NamedQuery(name = "UsuarioCli.findAll", query = "SELECT u FROM UsuarioCli u"),
    @NamedQuery(name = "UsuarioCli.findByIdCli", query = "SELECT u FROM UsuarioCli u WHERE u.idCli = :idCli"),
    @NamedQuery(name = "UsuarioCli.findByCpf", query = "SELECT u FROM UsuarioCli u WHERE u.cpf = :cpf")})
public class UsuarioCli implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idCli")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer idCli;
    @Basic(optional = false)
    @Column(name = "CPF")
    private String cpf;
    @JoinColumn(name = "Usuario_idUsuario", referencedColumnName = "idUsuario")
    @ManyToOne(optional = false,fetch=FetchType.LAZY)
    private Usuario usuario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usuarioCli")
    private Collection<Endereco> enderecoCollection;

    public UsuarioCli() {
    }

    public UsuarioCli(Integer idCli) {
        this.idCli = idCli;
    }

    public UsuarioCli(Integer idCli, String cpf) {
        this.idCli = idCli;
        this.cpf = cpf;
    }

    public Integer getIdCli() {
        return idCli;
    }

    public void setIdCli(Integer idCli) {
        this.idCli = idCli;
    }

    public String getCpf() {
        return cpf;
    }

    public void setCpf(String cpf) {
        this.cpf = cpf;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    public Collection<Endereco> getEnderecoCollection() {
        return enderecoCollection;
    }

    public void setEnderecoCollection(Collection<Endereco> enderecoCollection) {
        this.enderecoCollection = enderecoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCli != null ? idCli.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UsuarioCli)) {
            return false;
        }
        UsuarioCli other = (UsuarioCli) object;
        if ((this.idCli == null && other.idCli != null) || (this.idCli != null && !this.idCli.equals(other.idCli))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jpa.entities.UsuarioCli[idCli=" + idCli + "]";
    }

}
